package com.doraemon.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@EnableSwagger2 //必须存在
@Configuration //必须存在
 public class SwaggerConfig {
    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //为当前包路径
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("不二雄", "https://weibo.com/u/2394952241/home?wvr=5&lf=reg", "gyz_java@163.com");
        return new ApiInfo("Spring-demo后台台API接口",//大标题 title
                "Spring-demo后台台API接口",//小标题
                "0.0.1",//版本
                "www.github.com",//termsOfServiceUrl
                contact,//作者
                "不二雄的微博",//链接显示文字
                "https://weibo.com/u/2394952241/home?wvr=5&lf=reg"//网站链接
        );
    }
}